<?php
$valuearr = [];
if (isset($value) && $value) {
    $valuearr = json_decode($value, true);
}


foreach ($datasource as $data) {
?>
    <input type="radio" <?php echo in_array($data[$realvalue], $valuearr) ? 'checked' : '' ?> value="<?php echo $data[$realvalue] ?>" name="<?php echo $name ?>[]" title="<?php echo $data[$displayvalue] ?>" />
<?php
}
?>